<?php
$scs = array(
    'kontakty/ekb-ploshhad-1905-goda' => array('received' => 120, 'issued' => 100, 'workTime' => '10|20', 'holiday' => 7),
    'kontakty/msk-altufyevo' => array('received' => 410, 'issued' => 320, 'workTime' => '10|21', 'holiday' => false),
    'kontakty/msk-prospekt-vernadskogo' => array('received' => 130, 'issued' => 85, 'workTime' => '10|20', 'holiday' => 7),
    'kontakty/msk-voykovskaya' => array('received' => 350, 'issued' => 270, 'workTime' => '10|21', 'holiday' => 7),
    'kontakty/msk-gorbushka' => array('received' => 500, 'issued' => 430, 'workTime' => '7|21', 'holiday' => false),
    'kontakty/msk-domodedovskaya' => array('received' => 400, 'issued' => 300, 'workTime' => '10|22', 'holiday' => false),
    'kontakty/msk-kitay-gorod' => array('received' => 300, 'issued' => 180, 'workTime' => '10|21', 'holiday' => false),
    'kontakty/msk-novogireevo' => array('received' => 300, 'issued' => 180, 'workTime' => '10|21', 'holiday' => false),
    'kontakty/msk-teplyy-stan' => array('received' => 480, 'issued' => 310, 'workTime' => '10|22', 'holiday' => false),
    'kontakty/servis-centr-tehnoholl' => array('received' => 100, 'issued' => 60, 'workTime' => '10|20', 'holiday' => false),
    'kontakty/msk-shchelkovskaya' => array('received' => 200, 'issued' => 150, 'workTime' => '10|21', 'holiday' => false),
    'kontakty/nn-bolshaya-pokrovskaya' => array('received' => 150, 'issued' => 100, 'workTime' => '10|21', 'holiday' => false),
    'kontakty/prospekt-veteranov' => array('received' => 180, 'issued' => 160, 'workTime' => '10|20', 'holiday' => 7),
    'kontakty/spb-ploshchad-vosstaniya' => array('received' => 220, 'issued' => 200, 'workTime' => '10|21', 'holiday' => false),
    'kontakty/spb-kupchino' => array('received' => 190, 'issued' => 150, 'workTime' => '10|21', 'holiday' => false),
    'kontakty/bely-kuna' => array('received' => 140, 'issued' => 100, 'workTime' => '10|21', 'holiday' => false),
    'kontakty/spb-sadovaya' => array('received' => 350, 'issued' => 350, 'workTime' => '10|21', 'holiday' => false),
    'kontakty/kazan-sukonnaya-sloboda' => array('received' => 40, 'issued' => 30, 'workTime' => '10|20', 'holiday' => 7),
    'kontakty/msk-bratislavskaya' => array('received' => 150, 'issued' => 100, 'workTime' => '10|20', 'holiday' => false),
);
$data = isset($scs[$contact['pageUrl']]) ? $scs[$contact['pageUrl']] : array('received' => 350, 'issued' => 300, 'workTime' => '10|20', 'holiday' => false);

$recived = (int) $data['received'] / 5;
$issued = $data['issued'] / 5;

$today = date('w');
$currentTime = (int) date('H');
if ($data['holiday'] != $today) {
       
    $workTime = explode('|', $data['workTime']);
    $open = $workTime[0];
    $close = $workTime[1];
    if (($open <= $currentTime) && ($currentTime <= $close)) {
        $range = $close - $open;
        $totalTodayRecived = $recived / $range;
        $totalTodayIssued = $issued / $range;
        $totalCurrRecived = ($currentTime - $open) * $totalTodayRecived;
        $totalCurrIssued = ($currentTime - $open) * $totalTodayIssued;
        echo '<dl class="widget" id="sc-stat" style="display:none;">
                    <dt>Статистика СЦ на сегодня</dt>
                    <dd>
                    <div class="availability">
                        <ul style="text-align: left;" class="currency-icon">
                                <li style="margin: 0;padding-right: 20px;"><div style="width: 32px;" class="availability__icon"><img alt="icon" src="/themes/front/assets/images/prinyato.png"></div><p style="color: #636363;">Принято: ' . round($totalCurrRecived, 0, PHP_ROUND_HALF_UP) . '</p></li>
                                <li style="margin: 0;"><div style="width: 32px;" class="availability__icon"><img alt="icon" src="/themes/front/assets/images/vidano.png"></div><p style="color: #636363;">Выдано: ' . round($totalCurrIssued, 0, PHP_ROUND_HALF_UP) . '</p></li>                            
                        </ul>
                    </div>
                    </dd>
             </dl>';
    }
}

$content = str_replace("_TITLE_", $contact['pageFullTitle'], $contact['pageContentFull']);
$content = str_replace("_SHORT_CONTENT_", $contact['pageContentShort'], $content);
echo $content;
?>

<script>
    $(".availability").after($("#sc-stat"));
    $("#sc-stat").show();
</script>
<!-- Google Code for &#1082;&#1086;&#1085;&#1090;&#1072;&#1082;&#1090;&#1099; Conversion Page -->
<script type="text/javascript">
    / <![CDATA[ /
            var google_conversion_id = 956373091;
    var google_conversion_language = "en";
    var google_conversion_format = "3";
    var google_conversion_color = "ffffff";
    var google_conversion_label = "VWhTCKOsnlsQ47CEyAM";
    var google_remarketing_only = false;
    / ]]> /
</script>
<script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js">
</script>
<noscript>
<div style="display:inline;">
    <img height="1" width="1" style="border-style:none;" alt="" src="//www.googleadservices.com/pagead/conversion/956373091/?label=VWhTCKOsnlsQ47CEyAM&amp;guid=ON&amp;script=0"/>
</div>
</noscript>